﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;

namespace JMT.Data
{
    public sealed class JPackageContainer : IJPackageContainer
    {
        public event System.Collections.Specialized.NotifyCollectionChangedEventHandler JPackageCollectionChanged;

        ObservableCollection<JPackage> _collection;

        public JPackageContainer()
        {
            _collection = new ObservableCollection<JPackage>();
        }

        public void AddPackage(JPackage jPackage)
        {
            _collection.Add(jPackage);
        }

        public void RemovePackage(JPackage jPackage)
        {
            _collection.Remove(jPackage);
        }

        public JPackage GetPackage(Guid id)
        {
            foreach (var jPackage in _collection)
            {
                if (jPackage.Id == id)
                {
                    return jPackage;
                }
            }
            return null;
        }

        public List<JPackage> ToPackageList()
        {
            return _collection.ToList();
        }
    }
}
